home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
Views
/
Pane Frames
/
Frame.cp
next >
Wrap
Text File
|
2000-06-23
|
2KB
|
96 lines
// Frame.cp
#ifndef Frame_h
#include "Frame.h"
#endif
#ifndef MinMax_h
#include "MinMax.h"
#endif
#ifndef Overflow_h
#include "Overflow.h"
#endif
void Frame::Arrange( UPoint32 size )
{
Rectangle32 inside;
inside.left = Min( -thickness.left, Asint32(size.h) );
inside.top = Min( -thickness.top, Asint32(size.v) );
inside.right = Max( Asint32(size.h) - thickness.right, inside.left );
inside.bottom = Max( Asint32(size.v) - thickness.bottom, inside.top );
Rectangle32 outside( 0, 0, Asint32(size.h), Asint32(size.v) );
interior.SetBounds( inside );
exterior.SetBounds( outside );
}
int32 Frame::OuterWidth( int32 inner ) const
{
return ( inner < maxint32 - thickness.Width() )
? inner + thickness.Width()
: maxint32;
}
int32 Frame:: OuterHeight( int32 inner ) const
{
return ( inner < maxint32 - thickness.Height() )
? inner + thickness.Height()
: maxint32;
}
int32 Frame::MinimumWidth() const
{
return OuterWidth( interior.Sizer().MinimumWidth() );
}
int32 Frame:: MinimumHeight() const
{
return OuterHeight( interior.Sizer().MinimumHeight() );
}
int32 Frame:: MaximumWidth() const
{
return OuterWidth( interior.Sizer().MaximumWidth() );
}
int32 Frame:: MaximumHeight() const
{
return OuterHeight( interior.Sizer().MaximumHeight() );
}
int32 Frame:: ReasonableWidth() const
{
return OuterWidth( interior.Sizer().ReasonableWidth() );
}
int32 Frame:: ReasonableHeight() const
{
return OuterHeight( interior.Sizer().ReasonableHeight() );
}
int32 Frame::BestWidth( Range32 bounds ) const
{
int32 frameSize = thickness.Width();
if ( bounds.End() < frameSize )
return bounds.End();
Range32 innerBounds( bounds.Start() - Min( bounds.Start(), frameSize ),
bounds.End() - frameSize );
return OuterWidth( interior.Sizer().BestWidth( innerBounds ) );
}
int32 Frame::BestHeight( Range32 bounds ) const
{
int32 frameSize = thickness.Height();
if ( bounds.End() < frameSize )
return bounds.End();
Range32 innerBounds( bounds.Start() - Min( bounds.Start(), frameSize ),
bounds.End() - frameSize );
return OuterHeight( interior.Sizer().BestHeight( innerBounds ) );
}